package com.example.component.b_fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.component.R


class BFirstFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_b_first, container, false)
    }

    /**
     * 回调接口
     */
    interface OnFragmentInteractionListener {
        fun onFragmentInteraction(data: String)
    }

    private var mListener: OnFragmentInteractionListener? = null


    override fun onAttach(context: android.content.Context) {
        super.onAttach(context)
        if (context is OnFragmentInteractionListener) {
            mListener = context
        } else {
            throw RuntimeException("$context must implement OnFragmentInteractionListener")
        }
    }

    private fun sendDataToActivity(data: String) {
        mListener?.onFragmentInteraction(data)
    }
}